Allow excluding request logs for URI path patterns.#366
Allow excluding request logs for URI path patterns.#366KarstenSchnitter merged 3 commits intomainfrom
Conversation
Add servlet init parameter `excludePatterns` to configure a comma-separate list of ant-like patterns (wildcards "*" and "**") to exclude uris from request log generation. This can be used to suppress request logs from health or metrics endpoints. Signed-off-by: Karsten Schnitter <k.schnitter@sap.com>
Add benchmarks to ensure performance of URI filtering. The are executed as part of the Maven verify lifecycle phase when profile benchmark is active. The benchmarks show on my machine, that filtering without wildcards adds no more than 10ns and single wildcard matches no more than 40ns latency. Signed-off-by: Karsten Schnitter <k.schnitter@sap.com>
All JMH benchmarks now align in the profile benchmark. They can be executed with mvn verify -P benchmark Signed-off-by: Karsten Schnitter <k.schnitter@sap.com>
| } | ||
|
|
||
| @ParameterizedTest | ||
| @CsvSource({ "/actuator/**, /actuator/health", "/actuator/**, /actuator/health/liveness", |
There was a problem hiding this comment.
When reading the code and the docs it's quite obvious, but if I filter /actuator/** then /actuator without trailing slash is not covered. Do you think it makes sense to add a test case for this to make it more explicit? I think it doesn't deserve dedicated docs though
There was a problem hiding this comment.
I will be careful to mention this in the documentation. It will be added to the Instrumenting servlets. The pattern is supporting wildcards and them having influence on preceding characters could also be considered strange.
bennygoerzig
left a comment
There was a problem hiding this comment.
Have you considered the performance implications? If users construct complex patterns, this should really get out of hand if I got it correctly. I can't say though how weird the pattern would need to be to slow down the app itself, maybe you can judge this.
Also, since this lib is CF specific, maybe you could a specific example to the docstring (e.g., dropping /health). If you plan to add docs for this anyways, you can disregard this.
This is what the JMH benchmarks are for. On my machine I get those latency results: |
Adresses #324.
Provides an option to suppress request logs for comma-separated ant-like uri patterns. This allows to disable request log generation for health or monitoring endpoints.
The implementation comes with JMH benchmarks to ensure low latency due to filtering. The logback and log4j2 benchmarks were aligned to the servlet approach.